export function sleep(millisecond: number, isReject = false) {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      if (isReject) reject(false);
      else resolve(true);
    }, millisecond);
  });
}

export function range(
  ...args:
    | number[]
    | [end: number]
    | [start: number, end: number]
    | [start: number, end: number, step: number]
): number[] {
  const [start = 0, end, step = 1] = args.length === 1 ? [undefined, args[0]] : args;
  if (end === undefined) throw new Error("Missing end parameter");
  if (step === 0) throw new Error("range() step cannot be zero");
  let length = Math.max(0, Math.ceil((end - start) / step));
  return Array.from({ length }, (_, i) => start + i * step);
}
